#Boa:Dialog:ConsultasVarias

import wx
import consultasBD

def create(parent):
    return ConsultasVarias(parent)

[wxID_CONSULTASVARIAS, wxID_CONSULTASVARIASLISTBOX1, 
 wxID_CONSULTASVARIASPANEL1, 
] = [wx.NewId() for _init_ctrls in range(3)]

class ConsultasVarias(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_CONSULTASVARIAS,
              name='ConsultasVarias', parent=prnt, pos=wx.Point(474, 75),
              size=wx.Size(297, 485), style=wx.DEFAULT_DIALOG_STYLE,
              title='Consultas')
        self.SetClientSize(wx.Size(289, 458))

        self.panel1 = wx.Panel(id=wxID_CONSULTASVARIASPANEL1, name='panel1',
              parent=self, pos=wx.Point(0, 0), size=wx.Size(288, 456),
              style=wx.TAB_TRAVERSAL)

        self.listBox1 = wx.ListBox(choices=[], id=wxID_CONSULTASVARIASLISTBOX1,
              name='listBox1', parent=self.panel1, pos=wx.Point(8, 8),
              size=wx.Size(272, 440), style=0)
        self.listBox1.Bind(wx.EVT_LISTBOX_DCLICK, self.OnDobleClick,
              id=wxID_CONSULTASVARIASLISTBOX1)

    def __init__(self, parent, consultaSQL=""):
        self._init_ctrls(parent)
        resultado = consultasBD.ordenCruda(consultaSQL)
        for item in resultado:
            cadena = str(item[0])
            if str(item[1])<>" ":
                cadena+= " / "+str(item[1])
            self.listBox1.Append(cadena)

    def OnDobleClick(self, event):
        item = self.listBox1.GetStringSelection()
        self.id = item
        self.Close()
        
    def Muestraid(self):
        return self.id            
